//============================================================================
// Name        : Parser.h
// Author      : Casey Kelso
// Copyright   : Kineticsproject.com (c) 2010
// Description : Parser for ad2usb incoming data
// Created	   : September 14th 2010
//============================================================================

#ifndef PARSER_H_
#define PARSER_H_

#include <list>
#include "AlarmStatus.h"

using namespace std;

class Parser
{
public:
    enum eState {STATE_INITIAL,STATE_COLLECTING_STATUS_FIELD,STATE_STATUS_FIELD_END, STATE_COLLECTING_ZONE_FAULT,
             STATE_ZONE_FAULT_END, STATE_MESSAGE_END,STATE_UNKNOWN, STATE_IGNORE, STATE_COLLECTING_ALPHA_MESSAGE, STATE_WAITING_FOR_MESSAGE};

	Parser();
	virtual ~Parser();
	bool Process(const unsigned char* data, int size, list<AlarmStatus> &alarmStatusList);

private:
	bool validateCharacter(const unsigned char input, const unsigned char* charList, const int size);
    const unsigned char ENDOFLINE;
	const unsigned char STATUSFIELDSTART;
	const unsigned char STATUSFIELDEND;
	unsigned const int STATUSFIELDLENGTH;
	const unsigned char FIELDDELIMITER;
	const unsigned char ALPHAMESSAGEDELIMITER;


};

#endif /* PARSER_H_ */
